<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE html>
<html lang="en">
<head>
    <%@include file="../../common.jsp"%>
    <base href="<%=basePath%>">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <title>消缺记录统计</title>
</head>
<body>
<h2>消缺记录统计</h2>
<hr>
<form class="layui-form" action="">
    <div class="layui-form-item">

        <div class="layui-inline">
            <label class="layui-form-label">任务编号:</label>
            <div class="layui-input-inline" style="width: 200px;">
                <input id="inspectionTaskCode" type="text" name="inspectionTaskCode" autocomplete="off" class="layui-input">
            </div>
            <label class="layui-form-label">线路编号:</label>
            <div class="layui-input-inline" style="width: 200px;">
                <input id="lineCode" type="text" name="lineCode" autocomplete="off" class="layui-input">
            </div>
            <label class="layui-form-label">有无故障:</label>
            <div class="layui-input-inline">
                <select name="modules" lay-verify="required" lay-search="" id="isBug">
                    <option value="-1">请选择</option>
                    <option value="1">有</option>
                    <option value="0">无</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">消缺时间:</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="startTime" placeholder="yyyy-MM-dd">
            </div>
            <div class="layui-form-label" style="width:5px">-</div>
            <div class="layui-input-inline">
                <input type="text" class="layui-input testl" id="endTime" placeholder="yyyy-MM-dd">
            </div>


            <div class="layui-input-inline" style="width: 100px;">
                <button type="button" class="layui-btn layui-btn-normal" onclick="searchData();"><i class="layui-icon layui-icon-search"></i> 查询</button>
            </div>
        </div>

    </div>
</form>
<table class="layui-table" id="lineTable" lay-filter="lineTable"></table>

<script>

    //显示杆塔
    $.get("${path}/psPole/getPole",function (data) {
        $.each(data,function () {
            var option = $('<option></option>').appendTo("#pole");
            option.text(this.poleCode).val(this.id);
        });
    });
    //全局定义一次, 加载formSelects
    layui.config({
        base: '${path}/layui/lay/modules/' //此处路径请自行处理, 可以使用绝对路径
    }).extend({
        formSelects: 'formSelects-v4.min'
    });

    function searchData(){
        layui.table.reload("lineTable",{
            page:{
                curr : 1
            },
            where:{
                "startTime":$("#startTime").val(),
                "endTime":$("#endTime").val(),
                "inspectionTaskCode":$("#inspectionTaskCode").val(),
                "lineCode":$("#lineCode").val(),
                "isBug":$("#isBug").val()
            }
        });
    }

    layui.use(["table","form","laydate","formSelects"],function () {
        layui.use('laydate',function () {
            var laydate = layui.laydate;

            laydate.render({
                elem:'#startTime'
            });
            laydate.render({
                elem:'#endTime'
            });
            laydate.render({
                elem: '#issuedTime'
                ,value: new Date()
                ,isInitValue: true
            });
        });
        var table = layui.table;
        //获取数据渲染
        $.get("/statistical/solveTaskList",function (data) {
            table.render({
                id:'lineTable',
                elem:'#lineTable',
                url:'statistical/solveTaskList',
                page:true,
                even:false,
                cols:[[
                    {field:'psInspectiontask_main',title:'任务编码',templet:function (d) {
                            var name = "";
                            if(d.psInspectiontaskDetails.psInspectiontask_main != null){
                                name = d.psInspectiontaskDetails.psInspectiontask_main.inspectionTaskCode;
                            }
                            return name;
                        }},
                    {field:'psInspectiontask_main',title:'任务名称',templet:function (d) {
                            var name = "";
                            if(d.psInspectiontaskDetails.psInspectiontask_main != null){
                                name = d.psInspectiontaskDetails.psInspectiontask_main.inspectionTaskName;
                            }
                            return name;
                        }},
                    {field:'psInspectiontask_main',title:'线路编号',templet:function (d) {
                            var name = "";
                            if(d.psInspectiontaskDetails != null){
                                name = d.psInspectiontaskDetails.lineCode;
                            }
                            return name;
                        }},
                    {field:'psInspectiontask_main',title:'杆塔编号',templet:function (d) {
                            var name = "";
                            if(d.psInspectiontaskDetails != null){
                                name = d.psInspectiontaskDetails.poleCode;
                            }
                            return name;
                        }},
                    {field:'psInspectiontask_main',title:'有无故障',templet:function (d) {
                            var name = "";
                            if(d.psInspectiontaskDetails != null && d.psInspectiontaskDetails.isBug == 1){
                                name = "有"
                            }else if(d.psInspectiontaskDetails != null && d.psInspectiontaskDetails.isBug == 0){
                                name = "无"
                            }
                            return name;
                        }},
                    {field:'psInspectiontask_main',title:'缺陷级别',templet:function (d) {
                            var name = "";
                            if(d.psInspectiontaskDetails.bugLevelName != null){
                                name = d.psInspectiontaskDetails.bugLevelName;
                            }
                            return name;
                        }},
                    {field:'psInspectiontask_main',title:'缺陷类型',templet:function (d) {
                            var name = "";
                            if(d.psInspectiontaskDetails.bugTypeName != null){
                                name = d.psInspectiontaskDetails.bugTypeName;
                            }
                            return name;
                        }},
                    {field:'psInspectiontask_main',title:'消缺时间',templet:function (d) {
                            var name = "";
                            if(d.psSolvetaskMain != null){
                                name = d.psSolvetaskMain.finishTime;
                            }
                            return name;
                        }},
                    {field:'psInspectiontask_main',title:'发现时间',templet:function (d) {
                            var name = "";
                            if(d.psInspectiontaskDetails != null){
                                name = d.psInspectiontaskDetails.discoverTime;
                            }
                            return name;
                        }},
                    {field:'psInspectiontask_main',title:'缺陷描述',templet:function (d) {
                            var name = "";
                            if(d.psInspectiontaskDetails != null){
                                name = d.psInspectiontaskDetails.bugDesc;
                            }
                            return name;
                        }},
                ]]
            })
        })
    })
</script>

</body>
</html>